import { Platform, Dimensions, StatusBar } from 'react-native';

export const hasAnyFunction = (...codeList) => {
  if (!(global.functionList && Array.isArray(global.functionList) && codeList)) {
    return false;
  }
  for (let i = 0, codeLen = codeList.length; i < codeLen; i++) {
    for (let j = 0, functionLen = global.functionList.length; j < functionLen; j++) {
      const c = codeList[i].toLowerCase();
      const f = global.functionList[j].toLowerCase();
      if (c === f) {
        return true;
      }
    }
  }
  return false;
};

// 是否 isIphoneX
export function isIphoneX() {
  const dimen = Dimensions.get('window');
  return (
    Platform.OS === 'ios' &&
    !Platform.isPad &&
    !Platform.isTVOS &&
    (dimen.height === 812 || dimen.width === 812)
  );
}

// 获取头部填充高度
export function getHeaderPadding() {
    if (Platform.OS === 'android') {
        return StatusBar.currentHeight;
    }
    if (Platform.OS === 'ios') {
        if (isIphoneX()) {
            return 44;
        }
        return 20;
    }
}

// 获取头部高度
export function getHeaderHeight() {
    if (Platform.OS === 'android') {
        return 64;
    }
    if (Platform.OS === 'ios') {
        if (isIphoneX()) {
            return 88;
        }
        return 64;
    }
}


// 获取头部填充底部填充高度
export function getFooterBottom() {
  if (Platform.OS === 'android') {
    return 0;
  }
  if (Platform.OS === 'ios') {
    if (isIphoneX()) {
      return 34;
    }
    return 0;
  }
}
